package userInterface;

import java.awt.Container;

import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.JProgressBar;

public class BarUserInterfaceStrategy extends UserInterfaceStrategy implements TableModelListener{
	 JProgressBar bar = null;
	private static final long serialVersionUID = 1L;


	public BarUserInterfaceStrategy(DataModel model) {
		myModel=model;
		myModel.addTableModelListener(this);
		bar = new JProgressBar(0,30);
		tableChanged(null);
	}

	public Container getComponent() {
		return bar;
	}

	public void tableChanged(TableModelEvent arg0) {
		int r=myModel.getRowCount();
		if (r>0){
			String val=(String) myModel.getValueAt(r-1,1);
                        float f = Float.parseFloat(val);
			bar.setValue((int)f);
		}else{
			bar.setValue(0);
		}
	}

}
